<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class OpenSSL::SSL::SSLSocket - openssl: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="../Buffering.html">OpenSSL::Buffering</a>
    <li><a class="include" href="SocketForwarder.html">OpenSSL::SSL::SocketForwarder</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-open">::open</a>
    <li ><a href="#method-i-accept">#accept</a>
    <li ><a href="#method-i-accept_nonblock">#accept_nonblock</a>
    <li ><a href="#method-i-alpn_protocol">#alpn_protocol</a>
    <li ><a href="#method-i-cert">#cert</a>
    <li ><a href="#method-i-cipher">#cipher</a>
    <li ><a href="#method-i-client_ca">#client_ca</a>
    <li ><a href="#method-i-client_cert_cb">#client_cert_cb</a>
    <li ><a href="#method-i-connect">#connect</a>
    <li ><a href="#method-i-connect_nonblock">#connect_nonblock</a>
    <li ><a href="#method-i-export_keying_material">#export_keying_material</a>
    <li ><a href="#method-i-finished_message">#finished_message</a>
    <li ><a href="#method-i-hostname-3D">#hostname=</a>
    <li ><a href="#method-i-npn_protocol">#npn_protocol</a>
    <li ><a href="#method-i-peer_cert">#peer_cert</a>
    <li ><a href="#method-i-peer_cert_chain">#peer_cert_chain</a>
    <li ><a href="#method-i-peer_finished_message">#peer_finished_message</a>
    <li ><a href="#method-i-pending">#pending</a>
    <li ><a href="#method-i-post_connection_check">#post_connection_check</a>
    <li ><a href="#method-i-session">#session</a>
    <li ><a href="#method-i-session-3D">#session=</a>
    <li ><a href="#method-i-session_get_cb">#session_get_cb</a>
    <li ><a href="#method-i-session_new_cb">#session_new_cb</a>
    <li ><a href="#method-i-session_reused-3F">#session_reused?</a>
    <li ><a href="#method-i-ssl_version">#ssl_version</a>
    <li ><a href="#method-i-state">#state</a>
    <li ><a href="#method-i-stop">#stop</a>
    <li ><a href="#method-i-sysclose">#sysclose</a>
    <li ><a href="#method-i-sysread">#sysread</a>
    <li ><a href="#method-i-sysread_nonblock">#sysread_nonblock</a>
    <li ><a href="#method-i-syswrite">#syswrite</a>
    <li ><a href="#method-i-syswrite_nonblock">#syswrite_nonblock</a>
    <li ><a href="#method-i-tmp_dh_callback">#tmp_dh_callback</a>
    <li ><a href="#method-i-tmp_key">#tmp_key</a>
    <li ><a href="#method-i-using_anon_cipher-3F">#using_anon_cipher?</a>
    <li ><a href="#method-i-verify_result">#verify_result</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-OpenSSL::SSL::SSLSocket">
    <h1 id="class-OpenSSL::SSL::SSLSocket" class="class">
      class OpenSSL::SSL::SSLSocket
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-context" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">context</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>The <a href="SSLContext.html"><code>SSLContext</code></a> object used in this connection.</p>
              </div>
            </div>
          <div id="attribute-i-hostname" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">hostname</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-io" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">io</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>The underlying <a href="../../IO.html"><code>IO</code></a> object.</p>
              </div>
            </div>
          <div id="attribute-i-sync_close" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">sync_close</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Whether to close the underlying socket as well, when the SSL/TLS connection is shut down. This defaults to <code>false</code>.</p>
              </div>
            </div>
          <div id="attribute-i-to_io" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">to_io</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>The underlying <a href="../../IO.html"><code>IO</code></a> object.</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(io) &rarr; aSSLSocket
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(io, ctx) &rarr; aSSLSocket
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new <a href="../SSL.html"><code>SSL</code></a> socket from <em>io</em> which must be a real <a href="../../IO.html"><code>IO</code></a> object (not an IO-like object that responds to read/write).</p>

<p>If <em>ctx</em> is provided the <a href="../SSL.html"><code>SSL</code></a> Sockets initial params will be taken from the context.</p>

<p>The <a href="../Buffering.html"><code>OpenSSL::Buffering</code></a> module provides additional <a href="../../IO.html"><code>IO</code></a> methods.</p>

<p>This method will freeze the <a href="SSLContext.html"><code>SSLContext</code></a> if one is provided; however, session management is still allowed in the frozen <a href="SSLContext.html"><code>SSLContext</code></a>.</p>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE
ossl_ssl_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE io, v_ctx, verify_cb;
    SSL *ssl;
    SSL_CTX *ctx;

    TypedData_Get_Struct(self, SSL, &amp;ossl_ssl_type, ssl);
    if (ssl)
        ossl_raise(eSSLError, &quot;SSL already initialized&quot;);

    if (rb_scan_args(argc, argv, &quot;11&quot;, &amp;io, &amp;v_ctx) == 1)
        v_ctx = rb_funcall(cSSLContext, rb_intern(&quot;new&quot;), 0);

    GetSSLCTX(v_ctx, ctx);
    rb_ivar_set(self, id_i_context, v_ctx);
    ossl_sslctx_setup(v_ctx);

    if (rb_respond_to(io, rb_intern(&quot;nonblock=&quot;)))
        rb_funcall(io, rb_intern(&quot;nonblock=&quot;), 1, Qtrue);
    Check_Type(io, T_FILE);
    rb_ivar_set(self, id_i_io, io);

    ssl = SSL_new(ctx);
    if (!ssl)
        ossl_raise(eSSLError, NULL);
    RTYPEDDATA_DATA(self) = ssl;

    SSL_set_ex_data(ssl, ossl_ssl_ex_ptr_idx, (void *)self);
    SSL_set_info_callback(ssl, ssl_info_cb);
    verify_cb = rb_attr_get(v_ctx, id_i_verify_callback);
    // We don&#39;t need to trigger a write barrier because it&#39;s already
    // an instance variable of this object.
    SSL_set_ex_data(ssl, ossl_ssl_ex_vcb_idx, (void *)verify_cb);

    rb_call_super(0, NULL);

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Class Methods</h3>
                </header>

                  <div id="method-c-open" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          open(remote_host, remote_port, local_host=nil, local_port=nil, context: nil)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new instance of <a href="SSLSocket.html"><code>SSLSocket</code></a>. <em>remote</em>host_ and <em>remote</em>port_ are used to open TCPSocket. If <em>local</em>host_ and <em>local</em>port_ are specified, then those parameters are used on the local end to establish the connection. If <em>context</em> is provided, the <a href="../SSL.html"><code>SSL</code></a> Sockets initial params will be taken from the context.</p>

<h3 id="method-c-open-label-Examples">Examples<span><a href="#method-c-open-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h3>

<pre class="ruby"><span class="ruby-identifier">sock</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLSocket</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">&#39;localhost&#39;</span>, <span class="ruby-value">443</span>)
<span class="ruby-identifier">sock</span>.<span class="ruby-identifier">connect</span> <span class="ruby-comment"># Initiates a connection to localhost:443</span>
</pre>

<p>with SSLContext:</p>

<pre class="ruby"><span class="ruby-identifier">ctx</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLContext</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">sock</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLSocket</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">&#39;localhost&#39;</span>, <span class="ruby-value">443</span>, <span class="ruby-value">context:</span> <span class="ruby-identifier">ctx</span>)
<span class="ruby-identifier">sock</span>.<span class="ruby-identifier">connect</span> <span class="ruby-comment"># Initiates a connection to localhost:443 with SSLContext</span>
</pre>

                              <div class="method-source-code" id="open-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/ssl.rb, line 470</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">open</span>(<span class="ruby-identifier">remote_host</span>, <span class="ruby-identifier">remote_port</span>, <span class="ruby-identifier">local_host</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">local_port</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-value">context:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">sock</span> = <span class="ruby-operator">::</span><span class="ruby-constant">TCPSocket</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">remote_host</span>, <span class="ruby-identifier">remote_port</span>, <span class="ruby-identifier">local_host</span>, <span class="ruby-identifier">local_port</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLSocket</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">sock</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">return</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLSocket</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">context</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-accept" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          accept &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Waits for a SSL/TLS client to initiate a handshake.</p>

                              <div class="method-source-code" id="accept-source">
            <pre>static VALUE
ossl_ssl_accept(VALUE self)
{
    ossl_ssl_setup(self);

    return ossl_start_ssl(self, SSL_accept, &quot;SSL_accept&quot;, Qfalse);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-accept_nonblock" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          accept_nonblock([options]) &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Initiates the SSL/TLS handshake as a server in non-blocking manner.</p>

<pre class="ruby"><span class="ruby-comment"># emulates blocking accept</span>
<span class="ruby-keyword">begin</span>
  <span class="ruby-identifier">ssl</span>.<span class="ruby-identifier">accept_nonblock</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitReadable</span>
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>([<span class="ruby-identifier">s2</span>])
  <span class="ruby-keyword">retry</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitWritable</span>
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>(<span class="ruby-keyword">nil</span>, [<span class="ruby-identifier">s2</span>])
  <span class="ruby-keyword">retry</span>
<span class="ruby-keyword">end</span>
</pre>

<p>By specifying a keyword argument <em>exception</em> to <code>false</code>, you can indicate that <a href="SSLSocket.html#method-i-accept_nonblock"><code>accept_nonblock</code></a> should not raise an <a href="../../IO/WaitReadable.html"><code>IO::WaitReadable</code></a> or <a href="../../IO/WaitWritable.html"><code>IO::WaitWritable</code></a> exception, but return the symbol <code>:wait_readable</code> or <code>:wait_writable</code> instead.</p>

                              <div class="method-source-code" id="accept_nonblock-source">
            <pre>static VALUE
ossl_ssl_accept_nonblock(int argc, VALUE *argv, VALUE self)
{
    VALUE opts;

    rb_scan_args(argc, argv, &quot;0:&quot;, &amp;opts);
    ossl_ssl_setup(self);

    return ossl_start_ssl(self, SSL_accept, &quot;SSL_accept&quot;, opts);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-alpn_protocol" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          alpn_protocol &rarr; String | nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the ALPN protocol string that was finally selected by the server during the handshake.</p>

                              <div class="method-source-code" id="alpn_protocol-source">
            <pre>static VALUE
ossl_ssl_alpn_protocol(VALUE self)
{
    SSL *ssl;
    const unsigned char *out;
    unsigned int outlen;

    GetSSL(self, ssl);

    SSL_get0_alpn_selected(ssl, &amp;out, &amp;outlen);
    if (!outlen)
        return Qnil;
    else
        return rb_str_new((const char *) out, outlen);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-cert" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          cert &rarr; cert or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The <a href="../X509.html"><code>X509</code></a> certificate for this socket endpoint.</p>

                              <div class="method-source-code" id="cert-source">
            <pre>static VALUE
ossl_ssl_get_cert(VALUE self)
{
    SSL *ssl;
    X509 *cert = NULL;

    GetSSL(self, ssl);

    /*
     * Is this OpenSSL bug? Should add a ref?
     * TODO: Ask for.
     */
    cert = SSL_get_certificate(ssl); /* NO DUPs =&gt; DON&#39;T FREE. */

    if (!cert) {
        return Qnil;
    }
    return ossl_x509_new(cert);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-cipher" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          cipher &rarr; nil or [name, version, bits, alg_bits]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the cipher suite actually used in the current session, or nil if no session has been established.</p>

                              <div class="method-source-code" id="cipher-source">
            <pre>static VALUE
ossl_ssl_get_cipher(VALUE self)
{
    SSL *ssl;
    const SSL_CIPHER *cipher;

    GetSSL(self, ssl);
    cipher = SSL_get_current_cipher(ssl);
    return cipher ? ossl_ssl_cipher_to_ary(cipher) : Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-client_ca" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          client_ca &rarr; [x509name, ...]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the list of client CAs. Please note that in contrast to <a href="SSLContext.html#attribute-i-client_ca"><code>SSLContext#client_ca=</code></a> no array of <a href="../X509/Certificate.html"><code>X509::Certificate</code></a> is returned but <a href="../X509/Name.html"><code>X509::Name</code></a> instances of the CA’s subject distinguished name.</p>

<p>In server mode, returns the list set by <a href="SSLContext.html#attribute-i-client_ca"><code>SSLContext#client_ca=</code></a>. In client mode, returns the list of client CAs sent from the server.</p>

                              <div class="method-source-code" id="client_ca-source">
            <pre>static VALUE
ossl_ssl_get_client_ca_list(VALUE self)
{
    SSL *ssl;
    STACK_OF(X509_NAME) *ca;

    GetSSL(self, ssl);

    ca = SSL_get_client_CA_list(ssl);
    return ossl_x509name_sk2ary(ca);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-connect" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          connect &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Initiates an SSL/TLS handshake with a server.</p>

                              <div class="method-source-code" id="connect-source">
            <pre>static VALUE
ossl_ssl_connect(VALUE self)
{
    ossl_ssl_setup(self);

    return ossl_start_ssl(self, SSL_connect, &quot;SSL_connect&quot;, Qfalse);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-connect_nonblock" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          connect_nonblock([options]) &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Initiates the SSL/TLS handshake as a client in non-blocking manner.</p>

<pre class="ruby"><span class="ruby-comment"># emulates blocking connect</span>
<span class="ruby-keyword">begin</span>
  <span class="ruby-identifier">ssl</span>.<span class="ruby-identifier">connect_nonblock</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitReadable</span>
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>([<span class="ruby-identifier">s2</span>])
  <span class="ruby-keyword">retry</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitWritable</span>
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>(<span class="ruby-keyword">nil</span>, [<span class="ruby-identifier">s2</span>])
  <span class="ruby-keyword">retry</span>
<span class="ruby-keyword">end</span>
</pre>

<p>By specifying a keyword argument <em>exception</em> to <code>false</code>, you can indicate that <a href="SSLSocket.html#method-i-connect_nonblock"><code>connect_nonblock</code></a> should not raise an <a href="../../IO/WaitReadable.html"><code>IO::WaitReadable</code></a> or <a href="../../IO/WaitWritable.html"><code>IO::WaitWritable</code></a> exception, but return the symbol <code>:wait_readable</code> or <code>:wait_writable</code> instead.</p>

                              <div class="method-source-code" id="connect_nonblock-source">
            <pre>static VALUE
ossl_ssl_connect_nonblock(int argc, VALUE *argv, VALUE self)
{
    VALUE opts;
    rb_scan_args(argc, argv, &quot;0:&quot;, &amp;opts);

    ossl_ssl_setup(self);

    return ossl_start_ssl(self, SSL_connect, &quot;SSL_connect&quot;, opts);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-export_keying_material" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          export_keying_material(label, length) &rarr; String
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Enables use of shared session key material in accordance with RFC 5705.</p>

                              <div class="method-source-code" id="export_keying_material-source">
            <pre>static VALUE
ossl_ssl_export_keying_material(int argc, VALUE *argv, VALUE self)
{
    SSL *ssl;
    VALUE str;
    VALUE label;
    VALUE length;
    VALUE context;
    unsigned char *p;
    size_t len;
    int use_ctx = 0;
    unsigned char *ctx = NULL;
    size_t ctx_len = 0;
    int ret;

    rb_scan_args(argc, argv, &quot;21&quot;, &amp;label, &amp;length, &amp;context);
    StringValue(label);

    GetSSL(self, ssl);

    len = (size_t)NUM2LONG(length);
    str = rb_str_new(0, len);
    p = (unsigned char *)RSTRING_PTR(str);
    if (!NIL_P(context)) {
        use_ctx = 1;
        StringValue(context);
        ctx = (unsigned char *)RSTRING_PTR(context);
        ctx_len = RSTRING_LEN(context);
    }
    ret = SSL_export_keying_material(ssl, p, len, (char *)RSTRING_PTR(label),
                                     RSTRING_LENINT(label), ctx, ctx_len, use_ctx);
    if (ret == 0 || ret == -1) {
        ossl_raise(eSSLError, &quot;SSL_export_keying_material&quot;);
    }
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-finished_message" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          finished_message &rarr; &quot;finished message&quot;
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the last <strong>Finished</strong> message sent</p>

                              <div class="method-source-code" id="finished_message-source">
            <pre>static VALUE
ossl_ssl_get_finished(VALUE self)
{
    SSL *ssl;
    char sizer[1], *buf;
    size_t len;

    GetSSL(self, ssl);

    len = SSL_get_finished(ssl, sizer, 0);
    if (len == 0)
        return Qnil;

    buf = ALLOCA_N(char, len);
    SSL_get_finished(ssl, buf, len);
    return rb_str_new(buf, len);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-hostname-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          hostname = hostname &rarr; hostname
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the server hostname used for SNI. This needs to be set before <a href="SSLSocket.html#method-i-connect"><code>SSLSocket#connect</code></a>.</p>

                              <div class="method-source-code" id="hostname-3D-source">
            <pre>static VALUE
ossl_ssl_set_hostname(VALUE self, VALUE arg)
{
    SSL *ssl;
    char *hostname = NULL;

    GetSSL(self, ssl);

    if (!NIL_P(arg))
        hostname = StringValueCStr(arg);

    if (!SSL_set_tlsext_host_name(ssl, hostname))
        ossl_raise(eSSLError, NULL);

    /* for SSLSocket#hostname */
    rb_ivar_set(self, id_i_hostname, arg);

    return arg;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-npn_protocol" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          npn_protocol &rarr; String | nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the protocol string that was finally selected by the client during the handshake.</p>

                              <div class="method-source-code" id="npn_protocol-source">
            <pre>static VALUE
ossl_ssl_npn_protocol(VALUE self)
{
    SSL *ssl;
    const unsigned char *out;
    unsigned int outlen;

    GetSSL(self, ssl);

    SSL_get0_next_proto_negotiated(ssl, &amp;out, &amp;outlen);
    if (!outlen)
        return Qnil;
    else
        return rb_str_new((const char *) out, outlen);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-peer_cert" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          peer_cert &rarr; cert or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The <a href="../X509.html"><code>X509</code></a> certificate for this socket’s peer.</p>

                              <div class="method-source-code" id="peer_cert-source">
            <pre>static VALUE
ossl_ssl_get_peer_cert(VALUE self)
{
    SSL *ssl;
    X509 *cert = NULL;
    VALUE obj;

    GetSSL(self, ssl);

    cert = SSL_get_peer_certificate(ssl); /* Adds a ref =&gt; Safe to FREE. */

    if (!cert) {
        return Qnil;
    }
    obj = ossl_x509_new(cert);
    X509_free(cert);

    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-peer_cert_chain" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          peer_cert_chain &rarr; [cert, ...] or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The <a href="../X509.html"><code>X509</code></a> certificate chain for this socket’s peer.</p>

                              <div class="method-source-code" id="peer_cert_chain-source">
            <pre>static VALUE
ossl_ssl_get_peer_cert_chain(VALUE self)
{
    SSL *ssl;
    STACK_OF(X509) *chain;
    X509 *cert;
    VALUE ary;
    int i, num;

    GetSSL(self, ssl);

    chain = SSL_get_peer_cert_chain(ssl);
    if(!chain) return Qnil;
    num = sk_X509_num(chain);
    ary = rb_ary_new2(num);
    for (i = 0; i &lt; num; i++){
        cert = sk_X509_value(chain, i);
        rb_ary_push(ary, ossl_x509_new(cert));
    }

    return ary;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-peer_finished_message" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          peer_finished_message &rarr; &quot;peer finished message&quot;
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the last <strong>Finished</strong> message received</p>

                              <div class="method-source-code" id="peer_finished_message-source">
            <pre>static VALUE
ossl_ssl_get_peer_finished(VALUE self)
{
    SSL *ssl;
    char sizer[1], *buf;
    size_t len;

    GetSSL(self, ssl);

    len = SSL_get_peer_finished(ssl, sizer, 0);
    if (len == 0)
        return Qnil;

    buf = ALLOCA_N(char, len);
    SSL_get_peer_finished(ssl, buf, len);
    return rb_str_new(buf, len);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-pending" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          pending &rarr; Integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The number of bytes that are immediately available for reading.</p>

                              <div class="method-source-code" id="pending-source">
            <pre>static VALUE
ossl_ssl_pending(VALUE self)
{
    SSL *ssl;

    GetSSL(self, ssl);

    return INT2NUM(SSL_pending(ssl));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-post_connection_check" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          post_connection_check(hostname) &rarr; true
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Perform hostname verification following RFC 6125.</p>

<p>This method MUST be called after calling <a href="SSLSocket.html#method-i-connect"><code>connect</code></a> to ensure that the hostname of a remote peer has been verified.</p>

                              <div class="method-source-code" id="post_connection_check-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/ssl.rb, line 397</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">post_connection_check</span>(<span class="ruby-identifier">hostname</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">peer_cert</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">msg</span> = <span class="ruby-string">&quot;Peer verification enabled, but no certificate received.&quot;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">using_anon_cipher?</span>
      <span class="ruby-identifier">msg</span> <span class="ruby-operator">+=</span> <span class="ruby-node">&quot; Anonymous cipher suite #{cipher[0]} was negotiated. &quot;</span> \
             <span class="ruby-string">&quot;Anonymous suites must be disabled to use peer verification.&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">SSLError</span>, <span class="ruby-identifier">msg</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span>.<span class="ruby-identifier">verify_certificate_identity</span>(<span class="ruby-identifier">peer_cert</span>, <span class="ruby-identifier">hostname</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">SSLError</span>, <span class="ruby-node">&quot;hostname \&quot;#{hostname}\&quot; does not match the server certificate&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-session" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          session &rarr; aSession
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the SSLSession object currently used, or nil if the session is not established.</p>

                              <div class="method-source-code" id="session-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/ssl.rb, line 418</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">session</span>
  <span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span><span class="ruby-operator">::</span><span class="ruby-constant">SessionError</span>
  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-session-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          session = session &rarr; session
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the <a href="Session.html"><code>Session</code></a> to be used when the connection is established.</p>

                              <div class="method-source-code" id="session-3D-source">
            <pre>static VALUE
ossl_ssl_set_session(VALUE self, VALUE arg1)
{
    SSL *ssl;
    SSL_SESSION *sess;

    GetSSL(self, ssl);
    GetSSLSession(arg1, sess);

    if (SSL_set_session(ssl, sess) != 1)
        ossl_raise(eSSLError, &quot;SSL_set_session&quot;);

    return arg1;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-session_reused-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          session_reused? &rarr; true | false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if a reused session was negotiated during the handshake.</p>

                              <div class="method-source-code" id="session_reused-3F-source">
            <pre>static VALUE
ossl_ssl_session_reused(VALUE self)
{
    SSL *ssl;

    GetSSL(self, ssl);

    return SSL_session_reused(ssl) ? Qtrue : Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-ssl_version" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          ssl_version &rarr; String
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a String representing the SSL/TLS version that was negotiated for the connection, for example “TLSv1.2”.</p>

                              <div class="method-source-code" id="ssl_version-source">
            <pre>static VALUE
ossl_ssl_get_version(VALUE self)
{
    SSL *ssl;

    GetSSL(self, ssl);

    return rb_str_new2(SSL_get_version(ssl));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-state" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          state &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>A description of the current connection state. This is for diagnostic purposes only.</p>

                              <div class="method-source-code" id="state-source">
            <pre>static VALUE
ossl_ssl_get_state(VALUE self)
{
    SSL *ssl;
    VALUE ret;

    GetSSL(self, ssl);

    ret = rb_str_new2(SSL_state_string(ssl));
    if (ruby_verbose) {
        rb_str_cat2(ret, &quot;: &quot;);
        rb_str_cat2(ret, SSL_state_string_long(ssl));
    }
    return ret;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sysclose" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          sysclose &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends “close notify” to the peer and tries to shut down the <a href="../SSL.html"><code>SSL</code></a> connection gracefully.</p>

<p>If <a href="SSLSocket.html#attribute-i-sync_close"><code>sync_close</code></a> is set to <code>true</code>, the underlying <a href="../../IO.html"><code>IO</code></a> is also closed.</p>

                              <div class="method-source-code" id="sysclose-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/ssl.rb, line 384</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">sysclose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">closed?</span>
  <span class="ruby-identifier">stop</span>
  <span class="ruby-identifier">io</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">sync_close</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sysread" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          sysread(length) &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          sysread(length, buffer) &rarr; buffer
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Reads <em>length</em> bytes from the <a href="../SSL.html"><code>SSL</code></a> connection.  If a pre-allocated <em>buffer</em> is provided the data will be written into it.</p>

                              <div class="method-source-code" id="sysread-source">
            <pre>static VALUE
ossl_ssl_read(int argc, VALUE *argv, VALUE self)
{
    return ossl_ssl_read_internal(argc, argv, self, 0);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-syswrite" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          syswrite(string) &rarr; Integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes <em>string</em> to the <a href="../SSL.html"><code>SSL</code></a> connection.</p>

                              <div class="method-source-code" id="syswrite-source">
            <pre>static VALUE
ossl_ssl_write(VALUE self, VALUE str)
{
    return ossl_ssl_write_internal(self, str, Qfalse);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-tmp_key" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          tmp_key &rarr; PKey or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the ephemeral key used in case of forward secrecy cipher.</p>

                              <div class="method-source-code" id="tmp_key-source">
            <pre>static VALUE
ossl_ssl_tmp_key(VALUE self)
{
    SSL *ssl;
    EVP_PKEY *key;

    GetSSL(self, ssl);
    if (!SSL_get_server_tmp_key(ssl, &amp;key))
        return Qnil;
    return ossl_pkey_new(key);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-verify_result" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          verify_result &rarr; Integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the result of the peer certificates verification.  See verify(1) for error values and descriptions.</p>

<p>If no peer certificate was presented X509_V_OK is returned.</p>

                              <div class="method-source-code" id="verify_result-source">
            <pre>static VALUE
ossl_ssl_get_verify_result(VALUE self)
{
    SSL *ssl;

    GetSSL(self, ssl);

    return LONG2NUM(SSL_get_verify_result(ssl));
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-client_cert_cb" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">client_cert_cb</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="client_cert_cb-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/ssl.rb, line 432</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">client_cert_cb</span>
  <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">client_cert_cb</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-session_get_cb" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">session_get_cb</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="session_get_cb-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/ssl.rb, line 444</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">session_get_cb</span>
  <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">session_get_cb</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-session_new_cb" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">session_new_cb</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="session_new_cb-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/ssl.rb, line 440</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">session_new_cb</span>
  <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">session_new_cb</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-stop" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          stop &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sends “close notify” to the peer and tries to shut down the <a href="../SSL.html"><code>SSL</code></a> connection gracefully.</p>

                              <div class="method-source-code" id="stop-source">
            <pre>static VALUE
ossl_ssl_stop(VALUE self)
{
    SSL *ssl;
    int ret;

    GetSSL(self, ssl);
    if (!ssl_started(ssl))
        return Qnil;
    ret = SSL_shutdown(ssl);
    if (ret == 1) /* Have already received close_notify */
        return Qnil;
    if (ret == 0) /* Sent close_notify, but we don&#39;t wait for reply */
        return Qnil;

    /*
     * XXX: Something happened. Possibly it failed because the underlying socket
     * is not writable/readable, since it is in non-blocking mode. We should do
     * some proper error handling using SSL_get_error() and maybe retry, but we
     * can&#39;t block here. Give up for now.
     */
    ossl_clear_error();
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sysread_nonblock" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          sysread_nonblock(length) &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          sysread_nonblock(length, buffer) &rarr; buffer
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          sysread_nonblock(length[, buffer [, opts]) &rarr; buffer
                              </span>
                            </div>

                            <div class="method-description">
                              <p>A non-blocking version of <a href="SSLSocket.html#method-i-sysread"><code>sysread</code></a>.  Raises an <a href="SSLError.html"><code>SSLError</code></a> if reading would block.  If “exception: false” is passed, this method returns a symbol of :wait_readable, :wait_writable, or nil, rather than raising an exception.</p>

<p>Reads <em>length</em> bytes from the <a href="../SSL.html"><code>SSL</code></a> connection.  If a pre-allocated <em>buffer</em> is provided the data will be written into it.</p>

                              <div class="method-source-code" id="sysread_nonblock-source">
            <pre>static VALUE
ossl_ssl_read_nonblock(int argc, VALUE *argv, VALUE self)
{
    return ossl_ssl_read_internal(argc, argv, self, 1);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-syswrite_nonblock" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          syswrite_nonblock(string) &rarr; Integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes <em>string</em> to the <a href="../SSL.html"><code>SSL</code></a> connection in a non-blocking manner.  Raises an <a href="SSLError.html"><code>SSLError</code></a> if writing would block.</p>

                              <div class="method-source-code" id="syswrite_nonblock-source">
            <pre>static VALUE
ossl_ssl_write_nonblock(int argc, VALUE *argv, VALUE self)
{
    VALUE str, opts;

    rb_scan_args(argc, argv, &quot;1:&quot;, &amp;str, &amp;opts);

    return ossl_ssl_write_internal(self, str, opts);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-tmp_dh_callback" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">tmp_dh_callback</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="tmp_dh_callback-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/ssl.rb, line 436</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">tmp_dh_callback</span>
  <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">tmp_dh_callback</span> <span class="ruby-operator">||</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLContext</span><span class="ruby-operator">::</span><span class="ruby-constant">DEFAULT_TMP_DH_CALLBACK</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-using_anon_cipher-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">using_anon_cipher?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="using_anon_cipher-3F-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/ssl.rb, line 426</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">using_anon_cipher?</span>
  <span class="ruby-identifier">ctx</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLContext</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">ciphers</span> = <span class="ruby-string">&quot;aNULL&quot;</span>
  <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">ciphers</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">cipher</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

